function Sound(){
    this.soundOn = true;
    this.curSfxId = null;
    this.bgmIsPlayed = false;
    this.instance = cc.AudioEngine.getInstance();
}

var sound = new Sound();

Sound.prototype.switchOnOff = function(){
    sound.soundOn = !sound.soundOn;
    if (sound.soundOn) {
        cc.log("sound on");
        storage.set("SOUND", true);
        sound.playBGM();
    } else {
        cc.log("sound off");
        storage.set("SOUND", false);
        sound.stopBGM();
    }
}

Sound.prototype.isSoundOn = function(){
    sound.soundOn = storage.get("SOUND") === "true" ? true : false;
    return sound.soundOn;
}

Sound.prototype.playSfx = function(sfx){
    if (sound.soundOn && storage.get("SOUND") === "true") {
        sound.curSfxId = sound.instance.playEffect(sfx, false);
    }
}

Sound.prototype.playButtonSound = function(){
    sound.playSfx(s_buttonEffect_wav);
}

Sound.prototype.playBGM = function(){
    if (!sound.instance.isMusicPlaying() && storage.get("SOUND") === "true") {
        sound.instance.setMusicVolume(0.7);
        sound.instance.playMusic(s_bgMusic_mp3, true);
        sound.bgmIsPlayed = true;
    }
}

Sound.prototype.stopBGM = function(){
    sound.instance.stopMusic();
}

Sound.prototype.playFailSound = function(){
    sound.playSfx(s_failEffect_wav);
}

Sound.prototype.playFillSound = function(){
    sound.playSfx(s_fillEffect_wav);
}

Sound.prototype.playSuccessSound = function(){
    sound.playSfx(s_successEffect_wav);
}

Sound.prototype.playCheersSound = function(){
    sound.playSfx(s_cheersEffect_wav);
}
